/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package io.renren.modules.app.service.company.impl;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.exception.RRException;
import io.renren.common.validator.Assert;
import io.renren.modules.app.dao.company.CompanyUserDao;
import io.renren.modules.app.dao.company.YcCollectCompanyDao;
import io.renren.modules.app.dao.company.YcCompanyDao;
import io.renren.modules.app.dao.company.YcScaleDao;
import io.renren.modules.app.dao.index.*;
import io.renren.modules.app.dao.info.PositionTypeDao;
import io.renren.modules.app.dao.info.WorkYearDao;
import io.renren.modules.app.dao.info.YcBidDao;
import io.renren.modules.app.entity.YcSalaryEntity;
import io.renren.modules.app.entity.company.CompanyEntity;
import io.renren.modules.app.entity.company.YcCompanyEntity;
import io.renren.modules.app.entity.company.YcRecordRecruitEntity;
import io.renren.modules.app.entity.company.YcScaleEntity;
import io.renren.modules.app.entity.index.*;
import io.renren.modules.app.entity.info.PositionTypeEntity;
import io.renren.modules.app.entity.info.WorkYearEntity;
import io.renren.modules.app.entity.info.YcBidEntity;
import io.renren.modules.app.form.LoginForm;
import io.renren.modules.app.service.company.CompanyUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.time.LocalDate;
import java.util.*;

@Slf4j
@Service("CompanyUserService")
@RequiredArgsConstructor
public class CompanyUserServiceImpl extends ServiceImpl<CompanyUserDao, CompanyEntity> implements CompanyUserService {

	private final WorkYearDao ycWorkYearDao;
	private final YcScaleDao ycScaleDao;
	private final YcCompanyDao ycCompanyDao;
	private final CompanyUserDao companyUserDao;
	private final YcRecruitDao ycRecruitDao;
	private final YcEduBgdDao ycEduBgdDao;
	private final PositionTypeDao positionTypeDao;
	private final YcBidRecordDao ycBidRecordDao;
	private final YcRecruitTypeDao ycRecruitTypeDao;
	private final YcSalaryDao ycSalaryDao;
	private final YcRegionDao ycRegionDao;
	private final YcBidDao ycBidDao;

	/**
	 * 新增
	 * @param user
	 * @return
	 */
	@Override
	public int insert(CompanyEntity user) {

		return baseMapper.insert(user);
	}
//	@Override
//	public UserEntity queryByUserName(String username) {
//		return baseMapper.selectOne(new QueryWrapper<UserEntity>().eq("mobile", mobile));
//	}

	@Override
	public long login(LoginForm form) {

		CompanyEntity user =  baseMapper.selectOne(new QueryWrapper<CompanyEntity>().eq("account_name",form.getMobile()));
		Assert.isNull(user, "手机号或密码错误");

		//密码错误
		if(!user.getPassword().equals(DigestUtils.sha256Hex(form.getPassword()))){
			throw new RRException("手机号或密码错误");
		}

//		return user.getUserId();
		return user.getId();
	}

	@Override
	public Map<String, Object> login(Map<String, Object> map) {
		//创建返回map
		Map<String,Object> result = new HashMap<>();
		//根据用户名查询用户
		CompanyEntity user = baseMapper.selectOne(new QueryWrapper<CompanyEntity>().eq("account_name",map.get("loginAccountName").toString()));
		//用户为空代表该手机号未注册
		if(user == null){
			result.put("code",-100);
			result.put("msg","该手机号未注册");
			return result;
		}

		//密码错误
		if(!user.getPassword().equals(DigestUtils.sha256Hex(map.get("loginPassword").toString()))){
			result.put("code",-101);
			result.put("msg","密码错误");
			return result;
		}
		//手机号和密码输入正确
		result.put("code",200);
		result.put("msg","登录成功");
		result.put("companyUser",user);
		return result;
	}


	/**
	 * 获取年限数据
	 */
	@Override
	public JSONArray getWorkYearDict() {
//		LambdaQueryWrapper wrapper = new LambdaQueryWrapper();

		//和前端对应。前端是4层数据stateLimit， stateLimit: [//第一层 数组
		//        {//第二层 对象
		//          values: [//第四层，对象]//第三层数组
		//        }
		//      ],
		//从里往外，一层一层加


		JSONArray yearArray = new JSONArray();
		ycWorkYearDao.selectList(new LambdaQueryWrapper<WorkYearEntity>())//WorkYearEntity相当数据库表对应的实体类。就查这张表
			.forEach(item -> {
				//result是第四层
				JSONObject result = new JSONObject();//new出json对象，数组中是每个对象
				result.put("id", item.getId());//id对应的编号
				result.put("name", item.getWorkYear());//name是“不限” “1-3”年。。。
				//将他放到第三层yearArray数组里
				yearArray.add(result);
		});
		JSONArray one = new JSONArray();
		JSONObject two = new JSONObject();
		//第2层是对象（第三层yearArray数组，放到第二层里）
		two.put("values", yearArray);
		//第一层是数组， 将第二层对象，放到第一层数组里
		one.add(two);
		return one;
	}

	/**
	 * 获取年限数据
	 */
	@Override
	public JSONArray getEduBgdDict() {
		JSONArray yearArray = new JSONArray();
		ycEduBgdDao.selectList(new LambdaQueryWrapper<YcEduBgdEntity>())
				.forEach(item -> {
					JSONObject result = new JSONObject();
					result.put("id", item.getId());
					result.put("name", item.getEduBgd());
					yearArray.add(result);
				});
		JSONArray one = new JSONArray();
		JSONObject tew = new JSONObject();
		tew.put("values", yearArray);
		one.add(tew);
		return one;
	}

	/**
	 * 获取职位种类
	 */
	@Override
	public JSONArray getPositionTypeDict() {
		JSONArray yearArray = new JSONArray();
		positionTypeDao.selectList(new LambdaQueryWrapper<PositionTypeEntity>())
				.forEach(item -> {
					JSONObject result = new JSONObject();
					result.put("id", item.getId());
					result.put("name", item.getPositionTitle());
					yearArray.add(result);
				});
		JSONArray one = new JSONArray();
		JSONObject tew = new JSONObject();
		tew.put("values", yearArray);
		one.add(tew);
		return one;
	}

	/**
	 * 获取规模数据
	 */
	@Override
	public JSONArray getScaleDict() {
		JSONArray scaleArray = new JSONArray();
		ycScaleDao.selectList(new LambdaQueryWrapper<YcScaleEntity>())
			.forEach(item -> {
				JSONObject result = new JSONObject();
				result.put("id", item.getId());
				result.put("name", item.getNumber());
				scaleArray.add(result);
		});
		JSONArray one = new JSONArray();
		JSONObject tew = new JSONObject();
		tew.put("values", scaleArray);
		one.add(tew);
		return one;
	}

	/**
	 * 获取职位类型
	 */
	@Override
	public JSONArray getRecruitType() {
		JSONArray scaleArray = new JSONArray();
		ycRecruitTypeDao.selectList(new LambdaQueryWrapper<YcRecruitType>())
				.forEach(item -> {
					JSONObject result = new JSONObject();
					result.put("id", item.getId());
					result.put("name", item.getTypeName());
					scaleArray.add(result);
				});
		JSONArray one = new JSONArray();
		JSONObject tew = new JSONObject();
		tew.put("values", scaleArray);
		one.add(tew);
		return one;
	}

	/**
	 * 获取城市
	 */
	@Override
	public JSONArray getRegion() {
		JSONArray scaleArray = new JSONArray();
		ycRegionDao.selectList(new LambdaQueryWrapper<YcRegionEntity>().eq(YcRegionEntity::getLevel, 1))
				.forEach(item -> {
					JSONObject result = new JSONObject();
					result.put("id", item.getId());
					result.put("name", item.getName());
					scaleArray.add(result);
				});
		JSONArray one = new JSONArray();
		JSONObject tew = new JSONObject();
		tew.put("values", scaleArray);
		one.add(tew);
		return one;
	}

	/**
	 * 获取职位价格
	 */
	@Override
	public JSONArray getRecruitSalary() {
		JSONArray scaleArray = new JSONArray();
		ycSalaryDao.selectList(new LambdaQueryWrapper<YcSalaryEntity>())
			.forEach(item -> {
				JSONObject result = new JSONObject();
				result.put("id", item.getId());
				result.put("name", item.getSalaryRange());
				scaleArray.add(result);
			});
		JSONArray one = new JSONArray();
		JSONObject tew = new JSONObject();
		tew.put("values", scaleArray);
		one.add(tew);
		return one;
	}

	/**
	 * 新增企业数据
	 */
	@Override
	public YcCompanyEntity insertYcCompanyData(YcCompanyEntity company) {//新增将YcCompanyEntity company公司对象数据放到参数里
		//存放至编译文件处
		saveImageTarget(company.getLogo(), System.currentTimeMillis() + "");
		company.setAddtime(new Date());
		company.setVerifyStatus(0);//审核状态，默认为0，
		company.setMemberPoints(50);
		company.setLogo(saveImage(company.getLogo()));//将图片的base64.转为图片文件，存储到磁盘，返回相对路径
		boolean bool = ycCompanyDao.insert(company) > 0;//新增1条，大于0就代表新增成功。大于0，相当于true。新增数据获取返回值判断搜索是否成功
		if (bool) {
			company = ycCompanyDao.selectOne(new LambdaQueryWrapper<YcCompanyEntity>()//获取当前数据，返回给前台
					.orderByDesc(YcCompanyEntity::getAddtime).last(" limit 1 "));//通过时间降序，取最新的一条，就是新增的公司的id
			return company;
		}
		return null;
	}

	/**
	 * 修改企业数据
	 */
	@Override
	public boolean updateYcCompanyData(YcCompanyEntity company) {
		if (StringUtils.isNotEmpty(company.getLogo())) {
			if (company.getLogo().length() > 100) {
				String baseImage = company.getLogo();
				String filename = saveImage(baseImage);
				company.setLogo(filename);
				filename = filename.split("/")[1];
				saveImageTarget(baseImage, filename);
			}
		}
		return ycCompanyDao.updateById(company) > 0;
	}

	/*文件存储地址*/
	@Value("${file.save-path}")//yml的文件上传路径
	private String UPLOAD_SAVE_PATH;

	@Value("${file.target-path}")
	private String UPLOAD_TARGET_PATH;

	/**
	 * 生成文件
	 */
	private void saveImageTarget (String base64, String filename) {
		if (StringUtils.isNotEmpty(base64) && StringUtils.isNotEmpty(filename)) {
			byte[] decodedBytes = Base64.getDecoder().decode(base64);
			//组装存储路径
			String property = System.getProperty("file.separator");
			String parent_path = LocalDate.now().toString();
			//存贮至编译文件。前端可以直接访问。存到target下面的static的upload下
			String saveFilePath = (UPLOAD_TARGET_PATH + "/" + parent_path + "/").replaceAll("//", property);
			//检测文件路径是否存在
			if (!new File(saveFilePath).exists()) {
				new File(saveFilePath).mkdirs();
			}
			//生成文件名称
			String savePath = (saveFilePath + filename).replaceAll("//", property);
			try (OutputStream out = Files.newOutputStream(new File(savePath).toPath())) {
				out.write(decodedBytes);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 生成文件
	 */
	private String saveImage (String base64) {
		if (StringUtils.isNotEmpty(base64)) {
			byte[] decodedBytes = Base64.getDecoder().decode(base64);//获取base64后转成字节
			//组装存储路径
			String property = System.getProperty("file.separator");//获取系统的路径符号，window是/
			String parent_path = LocalDate.now().toString();//获取当前时间作为文件夹
			String saveFilePath = (UPLOAD_SAVE_PATH + "/" + parent_path + "/").replaceAll("//", property);//拼装文件磁盘存储路径
			//检测文件路径是否存在
			if (!new File(saveFilePath).exists()) {
				new File(saveFilePath).mkdirs();//不存在该路径就创建
			}
			//生成文件名称
			String filename = System.currentTimeMillis() + ".jpg";
			String savePath = (saveFilePath + filename).replaceAll("//", property);//拼装完整的存储路径含有文件名和文件格式
			try (OutputStream out = Files.newOutputStream(new File(savePath).toPath())) {//通过文件流把文件写入到系统文件里
				out.write(decodedBytes);
				return  parent_path + "/" + filename;//fan
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 新增企业人员
	 */
	@Override
	public boolean insertYcCompanyUserData(CompanyEntity company) {
		if (Objects.nonNull(company) && Objects.nonNull(company.getId())) {//如果公司id不为空，并且公司不为空
			//查询用户信息
			CompanyEntity currCompanyUser = companyUserDao.selectById(company.getId());//查询公司用户id
			if (Objects.nonNull(currCompanyUser)) {//如果公司用户不为空
				currCompanyUser.setCompanyId(company.getCompanyId());
				currCompanyUser.setUserPortrait(saveImage(company.getUserPortrait()));
				currCompanyUser.setUserName(company.getUserName());
				currCompanyUser.setSex(company.getSex());
				currCompanyUser.setUserPosition(company.getUserPosition());
				currCompanyUser.setMobile(company.getMobile());
				currCompanyUser.setEmail(company.getEmail());
				currCompanyUser.setAddtime(new Date());
				currCompanyUser.setUserStatus(0);
				currCompanyUser.setDeletestatus(false);//默认值软删除
				//存放至编译文件处
				saveImageTarget(company.getUserPortrait(), currCompanyUser.getUserPortrait());
				return companyUserDao.updateById(currCompanyUser) > 0;//通过id去更新数据
			}
		}
		return false;//不成功返回false
	}

	/**
	 * 修改企业人员
	 */
	@Override
	public boolean updateYcCompanyUserData(CompanyEntity company) {
		if (StringUtils.isNotEmpty(company.getUserPortrait())) {
			String image = company.getUserPortrait();
			if (image.length() > 100) {
				String filename = saveImage(image);
				company.setUserPortrait(filename);
				filename = filename.split("/")[1];
				saveImageTarget(image, filename);
			}
		}
		return companyUserDao.updateById(company) > 0;
	}

	/**
	 * 新增职位信息
	 */
	@Override
	public boolean insertYcRecruitData(YcRecruitEntity recruitEntity) {
		//前台传过来以后还需要这些数据
		recruitEntity.setAddtime(new Date());
		recruitEntity.setDeletestatus(false);
		recruitEntity.setModified(new Date());//更新时间
		recruitEntity.setRecruitStatus(1);//招聘状态，默认1是待审核
		return ycRecruitDao.insert(recruitEntity) > 0;
	}

	/**
	 * 查询职位列表
	 */
	@Override
	public List<YcRecruitEntity> selectRecruitList(YcRecruitEntity recruitEntity) {
		List<YcRecruitEntity> recruitEntities = new ArrayList<>();
		LambdaQueryWrapper<YcRecruitEntity> queryWrapper = new LambdaQueryWrapper<>();
		//YcRecruitEntity 是一个类，而 getCompanyId 是该类中的一个方法。:: 是方法引用运算符，用于创建对方法的引用。这里的含义是创建一个对 YcRecruitEntity 类的 getCompanyId 方法的引用。
		queryWrapper.eq(YcRecruitEntity::getCompanyId, recruitEntity.getCompanyId());
		queryWrapper.eq(YcRecruitEntity::getDeletestatus, false);
		recruitEntities = ycRecruitDao.selectList(queryWrapper);
		return recruitEntities;
	}

	/**
	 * 更新状态
	 */
	@Override
	public boolean updateRecruitStatus(String recruitId, String status) {
		if (StringUtils.isNotEmpty(recruitId) && StringUtils.isNotEmpty(status)) {
			YcRecruitEntity ycRecruitEntity = new YcRecruitEntity();
			if ("99".equals(status)) {
				ycRecruitDao.updateById(new YcRecruitEntity().setDeletestatus(true).setId(Integer.parseInt(recruitId)));
				ycBidRecordDao.updateById(new YcBidRecordEntity().setDeletestatus(true).setId(Integer.parseInt(recruitId)));
				return true;
			} else {
				ycRecruitEntity.setDeletestatus(false);
				ycRecruitEntity.setRecruitStatus(Integer.parseInt(status));
				ycRecruitEntity.setId(Integer.parseInt(recruitId));
			}
			return ycRecruitDao.updateById(ycRecruitEntity) > 0;
		}
		return false;
	}

	/**
	 * 更新竞价记录表数据状态
	 */
	@Override
	public boolean updateRecordRecruitStatus(String recruitId, boolean bool) {
		if (StringUtils.isNotEmpty(recruitId)) {
			try {
				YcBidRecordEntity ycBidRecord = new YcBidRecordEntity();
				ycBidRecord.setRecruitId(Integer.parseInt(recruitId));
				ycBidRecord.setDeletestatus(bool);
				ycBidRecord.setBidPoints(0);
				ycBidRecordDao.updateById(ycBidRecord);
				return true;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return false;
	}

	/**
	 * 查询职位招聘信息
	 */
	@Override
	public YcRecruitEntity getRecruitData (String id) {
		if (StringUtils.isNotEmpty(id)) {
			return ycRecruitDao.selectById(Integer.parseInt(id));
		}
		return null;
	}

	/**
	 * 查询职位招聘信息
	 */
	@Override
	public boolean updateRecruitBid (String id, String bid) {
		if (StringUtils.isNotEmpty(id) && StringUtils.isNotEmpty(bid)) {
			//查询职位信息
			YcRecruitEntity recruitEntity = ycRecruitDao.selectById(Integer.parseInt(id));
			ycBidRecordDao.update(null, new LambdaUpdateWrapper<YcBidRecordEntity>()
					.set(YcBidRecordEntity::getDeletestatus, true)
					.eq(YcBidRecordEntity::getRecruitId, id));
			if (Objects.nonNull(recruitEntity)) {
				YcBidRecordEntity bidRecordEntity = new YcBidRecordEntity();
				bidRecordEntity.setAddtime(new Date());
				bidRecordEntity.setDeletestatus(false);
				bidRecordEntity.setCompanyId(recruitEntity.getCompanyId());
				bidRecordEntity.setRecruitId(recruitEntity.getId());
				bidRecordEntity.setBidPoints(Integer.parseInt(bid));
				bidRecordEntity.setAccessNum(0);
				return ycBidRecordDao.insert(bidRecordEntity) > 0;
			}
		}
		return false;
	}

	/**
	 * 获取企业数据
	 */
	@Override
	public YcCompanyEntity getCompanyData(String id) {
		if (StringUtils.isNotEmpty(id)) {//id不为空就去查
			return ycCompanyDao.selectById(id);
		}
		return null;
	}

	/**
	 * 刷新竞价时间
	 */
	@Override
	public boolean reloadRecruitData(String id) {//根据id刷新竞价时间
		if (StringUtils.isNotEmpty(id)) {//如果util下的id不为空
			YcRecruitEntity recruitEntity = new YcRecruitEntity();//刷新职位信息竞价时间，更新数据
			recruitEntity.setId(Integer.parseInt(id)) //前端传递过来是string类型
					.setAddtime(new Date()).setModified(new Date());//
			return ycRecruitDao.updateById(recruitEntity) > 0; //大于0 表示有这条数据
		}
		return false;
	}

	/**
	 * 通过职位编号获取竞价相关数据
	 */
	@Override
	public JSONObject getBidRecruitData(String id, String bidPriceRecuritId){
		if (StringUtils.isNotEmpty(id)) {//检查 id 是否不为空。如果为空，直接返回一个空的 JSON 对象。
			JSONObject result = new JSONObject();//创建一个 JSON 对象，用于存储竞价信息。
			result.put("bef_bid", 0);//上次竞价积分 ,初始化，都将其设置为0
			result.put("cur_bid", 0);//本次竞价积分

//查询上次竞价数据：
			List<YcBidRecordEntity> YcRecruitEntity =
					ycBidRecordDao.selectList(new LambdaQueryWrapper<YcBidRecordEntity>()//使用 LambdaQueryWrapper 构建查询条件，查询 YcBidRecordEntity 表中符合条件的记录：
					.eq(YcBidRecordEntity::getCompanyId, id)
					.eq(YcBidRecordEntity::getDeletestatus, false)
					.eq(YcBidRecordEntity::getRecruitId, bidPriceRecuritId)
					.orderByDesc(YcBidRecordEntity::getAddtime)
					.last(" limit 1 "));//只需要数据库里最新的一条数据
			if (YcRecruitEntity.size() > 0) {//列表长度如果大于0，如果存在上次竞价数据
				result.put("bef_bid", YcRecruitEntity.get(0).getBidPoints());//"bef_bid"是返给前端的。将上次竞价积分设置为最新记录的竞价积分。
			}
 //查询本次竞价数据:
			List<YcBidEntity> ycBidEntities = ycBidDao.selectList(new LambdaQueryWrapper<YcBidEntity>());
			if (ycBidEntities.size() > 0) {//如果存在本次竞价数据
				result.put("cur_bid", ycBidEntities.get(0).getBidUnit());//将本次竞价积分设置为最新记录的竞价单位。
			}

			YcCompanyEntity company = ycCompanyDao.selectById(id);//通过公司ID查询公司信息。
			//查询总竞价积分
			result.put("member_points", Objects.isNull(company.getMemberPoints()) ? 0 : company.getMemberPoints());
			return result;
		}
		return new JSONObject();
	}

	@Override
	public boolean updateRecruitData(YcRecruitEntity recruitEntity) {
		if (Objects.nonNull(recruitEntity)
				&& StringUtils.isNotEmpty(String.valueOf(recruitEntity.getId()))) {
			recruitEntity.setRecruitStatus(1);
			recruitEntity.setModified(new Date());
			return ycRecruitDao.updateById(recruitEntity) > 0;
		}
		return false;
	}

	@Override
	public boolean deleteBidRecruitData(Integer companyId) {
		if (Objects.nonNull(companyId)) {
			return ycBidRecordDao.update(null, new LambdaUpdateWrapper<YcBidRecordEntity>()
					.eq(YcBidRecordEntity::getCompanyId, companyId)
					.set(YcBidRecordEntity::getDeletestatus, true)) > 0;
		}
		return false;
	}

	@Override
	public boolean updateRecruitBidData(YcRecordRecruitEntity recruitEntity) {
		if (Objects.nonNull(recruitEntity)) {
			try {
				//查询竞价数据
				List<YcBidRecordEntity> recordEntities =
						ycBidRecordDao.selectList(new LambdaQueryWrapper<YcBidRecordEntity>()
						.eq(YcBidRecordEntity::getRecruitId, recruitEntity.getRecruitId())
						.eq(YcBidRecordEntity::getDeletestatus, false)
						.orderByDesc(YcBidRecordEntity::getAddtime)
						.last(" limit 1 "));
				if (recordEntities.size() > 0) {
					YcBidRecordEntity ycBidRecordEntity = recordEntities.get(0);
					//获取竞价积分
					int points = ycBidRecordEntity.getBidPoints();
					//查询竞价
					int count = ycRecruitDao.selectUpdateBidRecordAddTime(
							String.valueOf(recruitEntity.getRecruitId()),
							recruitEntity.getIp());
					if (count > 0) { //超过一天
						ycRecruitDao.updateRecruitBid(String.valueOf(recruitEntity.getRecordId()), points);
					}
					//检测当前id和ip是否被用户点击过
					int exitsBid = ycRecruitDao.selectExitsBidData(String.valueOf(recruitEntity.getRecruitId()), recruitEntity.getIp());
					if (exitsBid == 0) {
						ycRecruitDao.updateRecruitBid(String.valueOf(recruitEntity.getRecordId()), points);
					}

					ycRecruitDao.insertRecruitRecord(recruitEntity);
					return true;
				}
			} catch (Exception e) {
				log.error("更新竞价积分异常 ==> [{}]", e.getMessage(), e);
			}
		}
		return false;
	}

	@Override
	public List<IndexRecruitEntity> selectRecruitCompanyBidData(){
		return ycRecruitDao.selectRecruitCompanyBidData();
	}


	/**
	 * 获取招聘人信息
	 */
	public CompanyEntity getCompanyUserData(String id) {
		return companyUserDao.selectById(id);
	}

	/**
	 * 更新公司竞价数据
	 */
	@Override
	public boolean updateCompanyPoints(String id, Integer points) {
		if (StringUtils.isNotEmpty(id) && Objects.nonNull(points)) {
			YcCompanyEntity company = ycCompanyDao.selectById(id);
			if (Objects.nonNull(company)) {
				company.setMemberPoints(company.getMemberPoints() + points);
				return ycCompanyDao.updateById(company) > 0;
			}
		}
		return false;
	}
}
